<template>
        <div class="out-style">
            <span class="span-first">商户支付参数配置</span>
            <Divider/>
            <div class="div-form">
                <Form :model="formItem" :label-width="100">
                    <FormItem label="subAppId:" prop="sub_app_id">
                        <Input v-model="formItem.sub_app_id" placeholder="请输入"></Input>
                    </FormItem>
                    <FormItem label="subMchId" prop="sub_mch_id">
                        <Input v-model="formItem.sub_mch_id" placeholder="请输入" ></Input>
                    </FormItem>
                </Form>
                <div class="foot-btn">
                    <Button type="primary" @click="savePay(formItem)" :loading="btnLoading">保存</Button>
                    <Button>取消</Button>
                </div>
            </div>
        </div>
</template>

<script>
import { insertWxPaySetting } from '@/api/shop'
export default {
  data () {
    return {
      formItem: {},
      btnLoading: false
    }
  },
  methods: {
    init () {},
    savePay () {
      this.btnLoading = true
      const param = {
        sub_app_id: this.formItem.sub_app_id,
        sub_mch_id: this.formItem.sub_mch_id
      }
      insertWxPaySetting(param).then(ret => {
        const data = ret.data
        if (data.errcode === 0) {
          this.btnLoading = false
          this.success()
        } else {
          this.error(data)
          this.btnLoading = false
        }
      })
    },
    success (val) {
      val = this.$common.xeUtils.isEmpty(val) ? '添加成功' : val
      this.$Message.success(val)
    },
    error (data) {
      this.$Message.error({
        content: '操作失败,\n' + data.errmsg
      })
    }
  }
}
</script>

<style scoped>
    .span-first {
        font-size: 16px;
        font-weight: 600;
    }
    .div-form {
        margin: 0 20px;
    }
    /deep/.ivu-input{
        width: 60%;
    }
    .foot-btn {
        text-align: left;
    }

    .foot-btn Button {
        margin-left: 30px;
        margin-top: 20px;
    }
</style>
